﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.ModelBinding;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;

namespace WebApp
{
    /// <summary>
    /// Summary description for WebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService
    {

        // methode om Companygegevens op te halen 
        [WebMethod]
        public DataSet getCompany()
        {
            DataAccess da = new DataAccess();
            return da.getCompany();
        }

        //methode om alle contract formules op te halen
        [WebMethod]
        public DataSet getContractFormulas()
        {
            DataAccess da = new DataAccess();
            return da.getContractFormulas();
        }

        // methode om Company te verwijderen
        [WebMethod]
        public bool removeCompany(int id)
        {
            DataAccess da = new DataAccess();
            da.removeCompany(id);
            return true;
        }

        // methode om ingegeven registerdata naar de tabel weg te schrijven
        [WebMethod]
        public bool registerCompany(string name, string street, int zipcode, string city, string country, string email, int phone, string employees)
        {
            DataAccess da = new DataAccess();
            da.insertCompany(name, street, zipcode, city, country, email, phone, employees);
            return true;
        }

        // methode om company aan te passen
        [WebMethod]
        public bool updateCompany(int id, string name, string street, int zipcode, string city, string country, string email, int phone, string employees)
        {
            DataAccess da = new DataAccess();
            da.updateCompany(id, name, street, zipcode, city, country, email, phone, employees);
            return true;
        }

        // Metode om contracten van het huidig bedrijf op te halen
        [WebMethod]
        public DataSet getContractsByCompayId(int id)
        {
            DataAccess da = new DataAccess();
            return da.getContractsByCompayId(id);
        }
        // methode om alle contracten op te halen 
        [WebMethod]
        public DataSet getAllContract()
        {
            DataAccess da = new DataAccess();
            return da.getAllContract();
        }

        // Verwijderd een contract   // storedprocedure nog niet aangemaakt
        [WebMethod]
        public bool deleteContract(int id)
        {
            DataAccess da = new DataAccess();
            da.deleteContract(id);
            return true;
        }

        // methode om reservaties in te geven
        [WebMethod]
        public int insertReservation(DateTime start, DateTime end, int company, string location)  
        {
            DataAccess da = new DataAccess();
            return da.insertReservation(start,end,company,location);
        }

        //methode om de reservaties per datum op te halen 
        [WebMethod]
        public DataSet getRegistratie(DateTime date)
        {
            DataAccess da = new DataAccess();
            return da.getReservation(date);
        }

        //methode om company info op te halen met als parameter de company naam
        [WebMethod]
        public DataSet getCompanyInfo(int Id)
        {
            DataAccess da = new DataAccess();
            return da.companyInfo(Id);
        }
        // telt het aantal records in de reservation tabel
      
        [WebMethod]
        public void setCompanyId(int Id, String Username)
        {
            UserProfile profile = UserProfile.getUserProfile(Username);
            profile.CompanyId = Id;
            profile.Save();
        }

        [WebMethod]
        public int getCompanyId(string Username)
        {
            UserProfile profile = UserProfile.getUserProfile(Username);
            return profile.CompanyId;
        }

        [WebMethod]
        public DataSet getUsernameReservation(int id)
        {
            DataAccess da = new DataAccess();
            return da.getUsernameReservation(id);
        }

        [WebMethod]
        public bool deleteReservation(int id)
        {
            DataAccess da = new DataAccess();
            da.deleteReservation(id);
            return true;
        }

        [WebMethod]
        public DataSet getAllReservations()
        {
            DataAccess da = new DataAccess();
            return da.getAllReservations();
        }

        [WebMethod]
        public bool eventContract(int Event, String userName, int contractId)
        {
            DataAccess da = new DataAccess();
            da.eventContract(Event, userName, contractId);
            return true;
        }

        [WebMethod]
        public bool eventReservation(int Event, String userName, String room, DateTime bookTime)
        {
            DataAccess da = new DataAccess();
            da.eventReservation(Event, userName, room, bookTime);
            return true;
        }

        [WebMethod]
        public DataSet getAllEvents()
        {
            DataAccess da = new DataAccess();
            return da.getAllEvents();
        }
        // methode om Contract aan te maken
        [WebMethod]
        public bool registerContract(DateTime startDate, DateTime endDate, int conCompId, int conFormId, int price)
        {
            DataAccess da = new DataAccess();
            da.registerContract(startDate, endDate, conCompId, conFormId, price);
            return true;
        }


        // methode om Contract aan te passen
        [WebMethod]
        public bool updateContract(int id, DateTime startDate, DateTime endDate, int conCompId, int conFormId)
        {
            DataAccess da = new DataAccess();
            da.updateContract(id, startDate, endDate, conCompId, conFormId);
            return true;
        }


        // methode om Contract aan te verwijderen  
        [WebMethod]
        public bool removeContract(int id)
        {
            DataAccess da = new DataAccess();
            da.removeContract(id);
            return true;
        }

        //methode om contract te cancellen (= endDate op vandaag zetten)
        [WebMethod]
        public bool cancelContract(int Id)
        {
            DataAccess da = new DataAccess();
            return da.cancelContract(Id);
        }


    }
}
